package com.mycookbook;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.util.Log;
import android.widget.EditText;

public class MyAdapter extends FragmentPagerAdapter {
	
	private static final String TAG = "LOL";
	protected static final String[] CONTENT = new String[] { "lol1", "lol2", "lol3", "lol4" };

    private int mCount = CONTENT.length;
    private Context context;
    
    private String recipeName;
    private String imageUrl;
	
	
    public MyAdapter(FragmentManager fm, Context context) {
        super(fm);
        this.context = context;
    }

    @Override
    public int getCount() {
        return mCount;
    }
    
    public void setCount(int count) {
        if (count > 0 && count <= 10) {
            mCount = count;
            notifyDataSetChanged();
        }
    }
    
    public void setRecipeName(String recipename){
    	recipeName = recipename;
    }
    
    public void setImageUrl(String imageurl){
    	imageUrl = imageurl;
    }

    @Override
    public Fragment getItem(int position) {
    	Log.i(TAG, "MainActivity getItem()");
    	ImageFragment imageFragment = new ImageFragment();
    	//EggTimerFragment eggtimerFragment = new EggTimerFragment();
        switch (position) {
        case 0:            	
        	return ImageFragment.newInstance(CONTENT[position % CONTENT.length], recipeName, R.drawable.steak, imageUrl); 
        	
		case 1:				
			return IngredientFragment.newInstance(recipeName);
			
        case 2:            	
        	return ApproachFragment.newInstance(recipeName);
        	
        case 3:
        	return EggTimerFragment.newInstance(0, R.id.buttonStartTimer);

        default:
        	return ImageFragment.newInstance(CONTENT[position % CONTENT.length], context.getString(R.string.steak), R.drawable.steak, imageUrl);
        }
    }
}
